package com.xdh.zzqh.store

import org.apache.poi.ss.usermodel.Row
import java.math.BigDecimal

class ExcelInfo(
    val products: List<Product>,
    val users: List<String>,
)

fun productWithRow(row: Row): Product? {

    val name = row.getCell(0)?.toString() ?: return null
    val style = row.getCell(1)?.toString() ?: return null
    val ty = row.getCell(2)?.toString() ?: return null
    val spec = row.getCell(3)?.toString() ?: return null
    val dir = row.getCell(4)?.toString() ?: return null
    val hands = row.getCell(5)?.toString() ?: return null
    val color = row.getCell(6)?.toString() ?: return null
    val price = row.getCell(7)?.toString()?.trim() ?: return null
    try {
        BigDecimal(price)
    } catch (e: Exception) {
        e.printStackTrace()
        return null
    }

    return Product(name, ty, style, spec, dir, hands, color, price)
}

fun userWithRow(row: Row): String? {
    return row.getCell(0)?.toString()
}
